package com.peas.platform.module.icims.contract.initial.api;

import cn.hutool.core.lang.Assert;
import com.peas.platform.common.core.dto.ResponseDto;
import com.peas.platform.module.icims.base.sys.enums.CommonOper;
import com.peas.platform.module.icims.contract.initial.api.req.*;
import com.peas.platform.module.icims.contract.initial.dto.ContractInitialDto;
import com.peas.platform.module.icims.contract.initial.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@Api(tags = "自定义接口-[合同管理]初始合同")
@RestController
@RequestMapping("/api/v1/customContractInitial")
public class CustomContractInitialController {

    @Resource
    private ContractInitialService contractInitialService;
    @Resource
    private ContractInitialSupplementalService contractInitialSupplementalService;
    @Resource
    private ContractInitialChangeService contractInitialChangeService;
    @Resource
    private ContractInitialCashService contractInitialCashService;
    @Resource
    private ContractInitialBorrowService contractInitialBorrowService;
    @Resource
    private ContractInitialCheckingService contractInitialCheckingService;
    @Resource
    private ContractInitialInterruptService contractInitialInterruptService;
    @Resource
    private ContractInitialTerminateService contractInitialTerminateService;

    @ApiOperation(value = "编辑保存合同")
    @PostMapping(value = "/saveContractInitial")
    public ResponseDto<ContractInitialDto> saveContractInitial(@RequestBody @Valid SaveContractInitialReq vo) {
        ContractInitialDto dto = contractInitialService.saveContractInitial(vo);
        return ResponseDto.getSuccessResponseDto(dto);
    }

    @ApiOperation(value = "编辑提交合同")
    @PostMapping("/submitContractInitial")
    public ResponseDto<Boolean> submitContractInitial(@RequestBody @Valid SubmitContractInitialReq vo) {
        contractInitialService.submitContractInitial(vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    @ApiOperation(value = "撤回合同")
    @PostMapping("/revocationContractInitial/{id}")
    public ResponseDto<Boolean> revocationContractInitial(@PathVariable("id") Long id) {
        contractInitialService.revocationContractInitial(id);
        return ResponseDto.getSuccessResponseDto(true);
    }

    @ApiOperation(value = "撤回合同补充协议")
    @PostMapping("/revocationContractInitialSupplemental/{id}")
    public ResponseDto<Boolean> revocationContractInitialSupplemental(@PathVariable("id") Long id) {
        contractInitialSupplementalService.revocationContractInitialSupplemental(id);
        return ResponseDto.getSuccessResponseDto(true);
    }

    @ApiOperation(value = "撤回合同变更")
    @PostMapping("/revocationContractInitialChange/{id}")
    public ResponseDto<Boolean> revocationContractInitialChange(@PathVariable("id") Long id) {
        contractInitialChangeService.revocationContractInitialChange(id);
        return ResponseDto.getSuccessResponseDto(true);
    }

    @ApiOperation(value = "撤回合同请款")
    @PostMapping("/revocationContractInitialCash/{id}")
    public ResponseDto<Boolean> revocationContractInitialCash(@PathVariable("id") Long id) {
        contractInitialCashService.revocationContractInitialCash(id);
        return ResponseDto.getSuccessResponseDto(true);
    }

    @ApiOperation(value = "撤回合同借阅")
    @PostMapping("/revocationContractInitialBorrow/{id}")
    public ResponseDto<Boolean> revocationContractInitialBorrow(@PathVariable("id") Long id) {
        contractInitialBorrowService.revocationContractInitialBorrow(id);
        return ResponseDto.getSuccessResponseDto(true);
    }

    @ApiOperation(value = "撤回合同验收")
    @PostMapping("/revocationContractInitialChecking/{id}")
    public ResponseDto<Boolean> revocationContractInitialChecking(@PathVariable("id") Long id) {
        contractInitialCheckingService.revocationContractInitialChecking(id);
        return ResponseDto.getSuccessResponseDto(true);
    }

    @ApiOperation(value = "撤回合同中止")
    @PostMapping("/revocationContractInitialInterrupt/{id}")
    public ResponseDto<Boolean> revocationContractInitialInterrupt(@PathVariable("id") Long id) {
        contractInitialInterruptService.revocationContractInitialInterrupt(id);
        return ResponseDto.getSuccessResponseDto(true);
    }

    @ApiOperation(value = "撤回合同终止")
    @PostMapping("/revocationContractInitialTerminate/{id}")
    public ResponseDto<Boolean> revocationContractInitialTerminate(@PathVariable("id") Long id) {
        contractInitialTerminateService.revocationContractInitialTerminate(id);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // 以下是合同执行
    // update 审批
    @ApiOperation(value = "初始合同执行-请款")
    @PostMapping("/cashContractInitial/{id}")
    public ResponseDto<Boolean> cashContractInitial(@PathVariable("id") Long id, @RequestBody @Valid CashContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.update.getKey(), "参数错误");
        contractInitialService.cashContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add 审批
    @ApiOperation(value = "初始合同执行-中止")
    @PostMapping("/interruptContractInitial/{id}")
    public ResponseDto<Boolean> interruptContractInitial(@PathVariable("id") Long id, @RequestBody @Valid InterruptContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.interruptContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add
    @ApiOperation(value = "初始合同执行-重启")
    @PostMapping("/restartContractInitial/{id}")
    public ResponseDto<Boolean> restartContractInitial(@PathVariable("id") Long id, @RequestBody @Valid RestartContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.restartContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // update 审批
    @ApiOperation(value = "初始合同执行-验收")
    @PostMapping("/checkingContractInitial/{id}")
    public ResponseDto<Boolean> checkingContractInitial(@PathVariable("id") Long id, @RequestBody @Valid CheckingContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.update.getKey(), "参数错误");
        contractInitialService.checkingContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add 审批
    @ApiOperation(value = "初始合同执行-补充协议")
    @PostMapping("/supplementalContractInitial/{id}")
    public ResponseDto<Boolean> supplementalContractInitial(@PathVariable("id") Long id, @RequestBody @Valid SupplementalContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.supplementalContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add 审批
    @ApiOperation(value = "初始合同执行-变更")
    @PostMapping("/changeContractInitial/{id}")
    public ResponseDto<Boolean> changeContractInitial(@PathVariable("id") Long id, @RequestBody @Valid ChangeContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.changeContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add
    @ApiOperation(value = "初始合同执行-转交")
    @PostMapping("/transferContractInitial/{id}")
    public ResponseDto<Boolean> transferContractInitial(@PathVariable("id") Long id, @RequestBody @Valid TransferContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.transferContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add
    @ApiOperation(value = "初始合同执行-登记纠纷")
    @PostMapping("/disputeContractInitial/{id}")
    public ResponseDto<Boolean> disputeContractInitial(@PathVariable("id") Long id, @RequestBody @Valid DisputeContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.disputeContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add
    @ApiOperation(value = "初始合同执行-授权")
    @PostMapping("/authorizationContractInitial/{id}")
    public ResponseDto<Boolean> authorizationContractInitial(@PathVariable("id") Long id, @RequestBody @Valid AuthorizationContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.authorizationContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add 审批
    @ApiOperation(value = "初始合同执行-终止")
    @PostMapping("/terminateContractInitial/{id}")
    public ResponseDto<Boolean> terminateContractInitial(@PathVariable("id") Long id, @RequestBody @Valid TerminateContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.terminateContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add
    @ApiOperation(value = "初始合同执行-生效")
    @PostMapping("/effectContractInitial/{id}")
    public ResponseDto<Boolean> effectContractInitial(@PathVariable("id") Long id, @RequestBody @Valid EffectContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.effectContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add
    @ApiOperation(value = "初始合同执行-完结")
    @PostMapping("/completeContractInitial/{id}")
    public ResponseDto<Boolean> completeContractInitial(@PathVariable("id") Long id, @RequestBody @Valid CompleteContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.completeContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add
    @ApiOperation(value = "初始合同执行-归档")
    @PostMapping("/archiveContractInitial/{id}")
    public ResponseDto<Boolean> archiveContractInitial(@PathVariable("id") Long id, @RequestBody @Valid ArchiveContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.archiveContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add 审批
    @ApiOperation(value = "初始合同执行-借阅")
    @PostMapping("/borrowContractInitial/{id}")
    public ResponseDto<Boolean> borrowContractInitial(@PathVariable("id") Long id, @RequestBody @Valid BorrowContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.borrowContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add
    @ApiOperation(value = "初始合同执行-跟踪")
    @PostMapping("/trackingContractInitial/{id}")
    public ResponseDto<Boolean> trackingContractInitial(@PathVariable("id") Long id, @RequestBody @Valid TrackingContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.trackingContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

    // add
    @ApiOperation(value = "初始合同执行-提醒")
    @PostMapping("/remindContractInitial/{id}")
    public ResponseDto<Boolean> remindContractInitial(@PathVariable("id") Long id, @RequestBody @Valid RemindContractInitialReq vo) {
        Assert.equals(vo.getOper(), CommonOper.add.getKey(), "参数错误");
        contractInitialService.remindContractInitial(id, vo);
        return ResponseDto.getSuccessResponseDto(true);
    }

}
